/*****************************************************************************
 * plum_hdl.h
 *
 * Copyright (C) 2020 Jeasonvor 1101627719@qq.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
#ifndef __PLUM_HDL_H__
#define __PLUM_HDL_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/*****************************************************************************
 * Public Types
 ****************************************************************************/

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  注册handle节点
 *
 * @param[in]:  malloc_func -       heap malloc函数指针
 * @param[in]:  data        -       私有数据指针
 *
 * @return: 成功    -   返回操作句柄
 *          失败    -   返回错误码
 *
 * @note:   plum各种类型的句柄都在此处进行注册，并统一管理
 */
plum_s32 plum_handle_register(plum_void *data);

/**
 * @brief:  删除handle节点
 *
 * @param[in]:  free_func   -   heap free函数指针
 * @param[in]:  id          -   节点ID
 *
 * @return: 返回错误码
 */
plum_s32 plum_handle_delete(plum_u32 id);

/**
 * @brief:  修改handle节点数据
 *
 * @param[in]:  id      -       handle节点ID
 * @param[in]:  data    -       节点私有数据指针
 *
 * @return: 返回错误码
 */
plum_s32 plum_handle_modify(plum_u32 id, plum_void *data);

/**
 * @brief： 查询句柄实体
 *
 * @param[in]:  id      -   操作句柄， plum_handle_register函数返回的handle
 *
 * @return: 返回句柄的私有数据指针
 */
plum_void *plum_handle_find(plum_u32 id);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_HDL_H__ */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
